<?php
// @formatter:off
/**
 * @file ct.comic.updatenames.php
 * @author Alejandro Dario Simi
 * @date $Date: 2013-06-22 17:58:11 +0000 (Sat, 22 Jun 2013) $
 *
 * $Id: ct.comic.updatenames.php 83 2013-06-22 17:58:11Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0-BETA2/cron/ct.comic.updatenames.php $
 */
// @formatter:on

class WCComicsUpdateNames extends WCCronTool {
	public function run($spacer = "") {
		global $wcGroupsHolder;
		foreach($wcGroupsHolder->groups() as $group) {
			if(is_readable($group->root)) {
				echo "{$spacer}Checking group '{$group->name}' ({$group->id}):\n";
				foreach($group->directoriesFull() as $directory) {
					foreach($directory->membersFull() as $comic) {
						if($comic->next_name) {
							echo "{$spacer}\tRenaming '{$comic->name}' in '{$comic->directory()->name}' to '{$comic->next_name}': ";
							if($comic->setNextName()) {
								echo WCColorText::ShellGreen("Done")."\n";
							} else {
								echo WCColorText::ShellRed("Failed")."\n";
							}
						}
					}
				}
			}
		}
	}
	public function showHelp($spacer = "") {
		echo "{$spacer}This tool seeks for any comic marked to be renamed and attempts to\n";
		echo "{$spacer}rename it.\n\n";
		echo "{$spacer}It requires no extra parameters.\n";
	}
	protected function loadOptions() {
		$this->_optionsLoaded = true;
	}
}
?>